/*
 * Project Name:yunjiafen
 * File Name:PageLimiter.java
 * Package Name:com.bestapp.yunjiafen.core.util
 * Date:2018年10月24日下午11:04
 * Copyright (c) 2018, bestapp All Rights Reserved.
 *
 */

package com.gitee.xmhzzz.component.spring.cloud.component.dao.context;


import com.gitee.xmhzzz.component.common.dto.PageBase;

/**
  * @ClassName
  * @Description 分页限制
  * @Author wzq
  * @Date 2023/12/15 16:49
  * @Version 1.0
  */
public class PageLimiter {
    /**
     * 最大页数
     */
    private int maxPage = 1000;

    /**
     * 每页最大数
     */
    private int maxSize = 500;

    public PageLimiter() {
    }

    public PageLimiter(int maxPage, int maxSize) {
        this.maxPage = maxPage;
        this.maxSize = maxSize;
    }

    public PageBase resetPage(PageBase page) {
        if (page == null) return null;
        if (page.getCurrent()> maxPage) {
            page.setCurrent(maxPage);
        }
        if (page.getSize() > maxSize) {
            page.setSize(maxSize);
        }
        return page;
    }
}
